package com.chen.service.role;

import com.chen.dao.BaseDao;
import com.chen.dao.role.RoleDao;
import com.chen.dao.role.RoleDaoImp;
import com.chen.pojo.Role;
import org.junit.Test;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;

public class RoleServiceImp implements RoleService{
    private RoleDao roleDao;
    public RoleServiceImp(){
        roleDao = new RoleDaoImp();
    }
    public List<Role> getRoleList(){
        Connection con = null;
        List<Role> roleList = null;
        try {
            con = BaseDao.getConnection();
            roleList = roleDao.getRoleList(con);
        } catch (SQLException e) {
            e.printStackTrace();
        }finally {
            BaseDao.closeResource(con,null,null);
        }
        return roleList;
    }
    @Test
    public void test(){
        RoleServiceImp roleServiceImp = new RoleServiceImp();
        List<Role> roleList = roleServiceImp.getRoleList();
        for (Role role : roleList) {
            System.out.println(role.getRoleName());
        }
    }
}
